package com.brayan.webapp.service.admin;

import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;

import com.brayan.webapp.model.general.country.Country;
import com.brayan.webapp.repository.general.country.CountryRepository;

@Stateless
public class AdminBean {

	@Inject
	CountryRepository countryRepo;

	/**
	 * Populate initial data e.g. countries, locale, etc.
	 * Not allowed if system is already initialized.
	 */
	public void initSystem() {
		if(!isSystemInitalized())
			countryRepo.repopulateCountryRepo();
	}

	public boolean isSystemInitalized() {
		// Add more checks to the system if necessary.
		return isInitDataLoaded();
	}

	private boolean isInitDataLoaded() {
		// Are 10 countries loaded?
		List<Country> listOfCountries = countryRepo.getAllCountries();
		if (listOfCountries.size() > 10)
			return true;
		else
			return false;
	}
}
